package com.cykj.faceledtv.utils;

import android.os.Environment;

import java.io.File;

/**
 * @author jzh
 * @date 2019/05/11 10:10
 */
public class FileUtils {
    /**
     * 获取人脸图片保存路径
     *
     * @return file
     */
    public static File getFaceDirectory() {
        File sdRootFile = getSDRootFile();
        File file = null;
        if (sdRootFile != null && sdRootFile.exists()) {
            file = new File(sdRootFile, "led/faceImg");
            if (!file.exists()) {
                file.mkdirs();
            }
        }
        return file;
    }

    /**
     * Gets the SD root file.
     *
     * @return the SD root file
     */
    public static File getSDRootFile() {
        if (isSdCardAvailable()) {
            return Environment.getExternalStorageDirectory();
        } else {
            return null;
        }
    }

    /**
     * Checks if is sd card available.
     *
     * @return true, if is sd card available
     */
    public static boolean isSdCardAvailable() {
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    }
}
